<template>
	<view>
		<topbar :is_back="false" title="登录"></topbar>
		<view class="content dis_f_co_c_c">
			<image class="logo" src="../../static/login/logo.jpg" mode="aspectFit"></image>

			<view class="dis_f_l_c text"
				style="border-bottom: 1rpx solid #EEEEEE;margin-bottom: 40rpx;color: #999;font-size: 34rpx;">
				<view style="margin-right: 20rpx;">账号</view>
				<u-input v-model="account" type="text" placeholder="请输入账号" maxlength="11" />
			</view>
			<view class="dis_f_l_c text"
				style="border-bottom: 1rpx solid #EEEEEE;margin-bottom: 40rpx;color: #999;font-size: 34rpx;">
				<view style="margin-right: 20rpx;">密码</view>
				<u-input v-model="password" type="password" placeholder="请输入密码" />
			</view>
			<view style="width: 100%;margin-bottom: 60rpx;font-size: 34rpx" @click="login">
				<view class="dis_f_c_c ws_btn" @click="login">登录</view>
			</view>
			<view class="kj_dl">
				<view class="tests dis_f_c_c">快捷登录</view>
			</view>
			<image src="../../static/login/wx1.png" class="wx_login" @click="logins"></image>
			<view class="dis_f_c_c" style="width: 100%;">
				<view>登录即代表同意相关</view>
				<view><text style="color: #23BAE8;" @click="go_xy(3)">《用户协议》</text>及<text style="color: #23BAE8;" @click="go_xy(2)">《隐私协议》</text></view>
			</view>
			
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				account: '',
				password: '',
			};
		},
		onLoad() {
			// let time = Math.round(new Date() / 1000)
			this.$.ajax(1,"POST","cesss",{
				uid:"16831",
				// time:163367459
			},(res)=>{
				console.log(res)
			})
		},
		methods:{
			go_xy(e){
				this.$.open('/pages/mine/xie_yi/zb_xy?type='+e)
			},
			logins(){
				var that = this
				uni.login({
				  provider: 'weixin',
				  success: function (loginRes) {
				    console.log(loginRes.authResult);
					that.$.ajax(1,"POST","login",{
						openid:loginRes.authResult.openid,
						access_token:loginRes.authResult.access_token,
						unionid:loginRes.authResult.unionid,
					},(res)=>{
						if(res.code ==1){
							that.$.set_data('uid',res.uid)
							that.$.ti_shi('登录成功')
							setTimeout(function() {
							that.$.open_tab('/pages/mine/mine')
							}, 1000);
						}else{
							this.$.ti_shi(res.msg)
						}
					})
				  }
				});
			},
			login(){
				var that = this
				this.$.ajax(1,"POST","login",{
					username:this.account,
					password:this.password
				},(res)=>{
					if(res.code ==1){
						that.$.set_data('uid',res.uid)
						that.$.ti_shi('登录成功')
						setTimeout(function() {
							that.$.open('/pages/mine/mine')
						// that.$.open_tab('/pages/mine/mine')
						}, 1000);
					}else{
						this.$.ti_shi(res.msg)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #fff !important;
		height: 100vh;
	}

	.content {
		width: 100%;
		padding: 220rpx 60rpx 0 60rpx;

		.logo {
			width: 400rpx;
			height: 200rpx;
			margin-bottom: 100rpx;
		}

		.text {
			color: #23BAE8;
			width: 100%;
			font-size: 32rpx;
			border-bottom: 1rpx solid #23BAE8;
			padding-bottom: 14rpx;
		}

		.ws_btn {
			width: 100%;
			height: 80rpx;
			background-color: #23BAE8;
			color: #FFF;
			border-radius: 12rpx;
		}
		.wx_login{
			width: 100rpx;
			height: 100rpx;
			margin-bottom: 40rpx;
		}
		.kj_dl {
			width: 100%;
			border-bottom: 1px solid #c8c8c8;
			position: relative;
			margin-bottom: 100rpx;
			.tests {
				position: absolute;
				background: #fff;
				padding: 0 10rpx;
				height: 40rpx;
				width: 160rpx;
				left: calc(50% - 80rpx);
				top: -20rpx;
				color: #c8c8c8;
			}
		}

	}
</style>
